import java.util.*;

/**
 * @author LKQ
 * @date 2022/3/20 14:59
 * @description 先排序 再逆序遍历，选择最长的三条边
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {3,6,3,2};
        solution.largestPerimeter(nums);
    }
    public int largestPerimeter(int[] A) {
        Arrays.sort(A);
        for (int i = A.length - 1; i >= 2; --i) {
            if (A[i - 2] + A[i - 1] > A[i]) {
                return A[i - 2] + A[i - 1] + A[i];
            }
        }
        return 0;
    }
}
